package org.example.gc;

public class HelpSelf {
	private static HelpSelf hs = null;

	@Override
	protected void finalize() throws Throwable {
		super.finalize();
		System.out.println("now in finalize===");
		//自救
		hs = this;
	}
	public static void main(String[] args) throws Exception{
		hs = new HelpSelf();
		
		//第一次
		hs = null;
		
		System.gc();
		Thread.sleep(1000L);
		
		System.out.println("first hs==="+hs);
		
		//第二次
		hs = null;
		
		System.gc();
		Thread.sleep(1000L);
		
		System.out.println("second hs==="+hs);
				
	}
	
}
